package com.xzr3;

interface DogState{
    void showState();
}

class Dog{
    DogState state;
    public void show(){
        state.showState();
    }
    public Dog(DogState dog){
        this.state = dog;
    }

}

class Eat implements DogState{

    @Override
    public void showState() {
        System.out.println("狗狗在吃饭呢！");
    }
}

class Play implements DogState{

    @Override
    public void showState() {
        System.out.println("狗狗在玩球呢！");
    }
}

class Pao implements DogState{

    @Override
    public void showState() {
        System.out.println("狗狗在跑步呢！");
    }
}

public class Dogtest {
    public static void main(String[] args) {
        Dog play = new Dog(new Play());
        play.show();

        Dog eat = new Dog(new Eat());
        eat.show();

        Dog pao = new Dog(new Pao());
        pao.show();



    }


}
